<template>
  <div class="user">
    <!-- 头部 -->
    <div class="search">
      <a-form style="padding-top: 20px" :model="form" :hideRequiredMark="true" :label-col="labelCol">
        <a-row :gutter="20">
          <a-col :span="6" :lg="5" :md="7" :xs="20">
            <a-form-item name="nickName" label="护士姓名">
              <a-input v-model:value="form.nickName" placeholder="请输入护士姓名"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="6" :lg="5" :md="6" :xs="20">
            <a-form-item name="nurseId" label="护士ID">
              <a-input v-model:value="form.nurseId" placeholder="请输入护士ID"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="6" :lg="5" :md="7" :xs="20">
            <a-form-item label="手机号">
              <a-input v-model:value="form.mobile" placeholder="请输入护士手机号"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="2" :lg="2" :xs="5">
            <a-button type="primary" @click="search" class="d-a-center">搜索</a-button>
          </a-col>
          <a-col :span="2" :xs="5" :lg="2">
            <a-button type="primary" @click="openDrawer" class="d-a-center">高级筛选</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <a-row justify="end" style="padding: 20px 0px" :gutter="20" v-has="{ a: $route, b: 2 }">
      <a-col :span="2" :offset="1" :xs="7" :lg="2">
        <a-button type="info" @click="exportData" class="d-a-center">导出客户数据</a-button>
      </a-col>
      <a-col :span="2" :offset="1" :xs="7" :lg="2">
        <a-button type="primary" @click="send" :loading="msgLoading" class="d-a-center">发送短信</a-button>
      </a-col>
      <a-col :span="2" :offset="1" :xs="7" :lg="2">
        <a-button type="info" @click="systemNotice" :loading="sysLoading" class="d-a-center">系统通知</a-button>
      </a-col>
    </a-row>
    <!-- 列表 -->
    <a-table
      :columns="columns"
      rowKey="nurseId"
      :data-source="list"
      bordered
      :loading="loading"
      :pagination="pagination"
      @change="handleTableChange"
      :row-selection="{ selectedRowKeys: rowSelection.selectedRowKeys, ...rowSelection }"
    >
      <!-- :scroll="{ y: 540, x: 'auto' }" -->

      <template #name="{ record }">
        <template v-if="record.name">
          {{ record.name }}
        </template>
        <template v-else>
          <a-tag color="warning">未实名</a-tag>
        </template>
      </template>
      <template #identity="{ record }">
        <div>{{ nurseType[record.identity] }}</div>
      </template>
      <template #status="{ record }">
        <a-tag>{{ statusMap[record.status] }}</a-tag>
        <!-- <a-switch
          v-model:checked="record.status"
          :checkedValue="1"
          :unCheckedValue="0"
          @change="changeStatus(record.status, index)"
        /> -->
      </template>
      <template #nameStatus="{ record }">
        <a-tag :color="record.nameStatus == 2 ? 'success' : 'warning'">{{ record.nameStatus == 2 ? '已实名' : '未实名' }}</a-tag>
        <!-- <a-switch
          v-model:checked="record.attestStatus"
          :checkedValue="1"
          :unCheckedValue="0"
          @change="changeStatus(record.attestStatus, index)"
        /> -->
      </template>
      <template #attestStatus="{ record }">
        <a-tag :color="record.attestStatus == 2 ? 'success' : 'warning'">{{ record.attestStatus == 2 ? '已认证' : '未认证' }}</a-tag>
      </template>
      <template #operation="{ record }">
        <div class="button-container">
          <a-button type="link" @click="look(record.nurseId, listPage, form, advancedForm, 0)" v-has="{ a: $route, b: 2 }">查看</a-button>
          <a-button type="link" @click="look(record.nurseId, listPage, form, advancedForm, 1)" v-has="{ a: $route, b: 2 }">编辑</a-button>
          <a-button type="link" danger @click="disable(record)">禁用</a-button>
        </div>

        <!-- <a-button type="link" @click="deal(record.key)">编辑</a-button> -->
      </template>
    </a-table>
    <a-divider></a-divider>

    <!-- 高级筛选抽屉 -->
    <a-drawer
      width="45%"
      :destroyOnClose="true"
      v-model:visible="visible"
      class="custom-class"
      title="高级筛选"
      placement="right"
      @close="cancel"
    >
      <a-form :label-col="labelCol" :model="advancedForm">
        <a-form-item label="地理位置">
          <a-input v-model:value="advancedForm.address" placeholder="请输入地理位置"></a-input>
        </a-form-item>
        <a-form-item label="资质认证">
          <a-select
            ref="select"
            v-model:value="advancedForm.attestStatus"
            style="width: 120px"
            @focus="focus"
            placeholder="请选择资质认证状态"
          >
            <a-select-option v-for="item in isRealNameList" :value="item.id" :key="item.id">{{ item.title }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="注册渠道">
          <a-select ref="select" v-model:value="advancedForm.registsource" style="width: 120px" @focus="focus" placeholder="请选择注册渠道">
            <a-select-option v-for="item in registSourceList" :value="item.title" :key="item.id">{{ item.title }}</a-select-option>
          </a-select>
          <!-- <a-input
            v-model="advancedForm.registsource"
            placeholder="请输入注册渠道"
            format="YYYY-MM-DD HH:mm:ss"
          ></a-input> -->
        </a-form-item>
        <a-form-item label="注册时间">
          <a-range-picker v-model:value="value1" @change="selectTime" />
        </a-form-item>
        <a-form-item label="接单数量">
          <a-slider
            v-model:value="sliderValue"
            @change="changeOrderNumber"
            range
            :tooltipVisible="true"
            :marks="marks"
            :min="0"
            :max="999"
          />
        </a-form-item>
        <a-form-item label="所属医院">
          <a-input v-model:value="advancedForm.hospitalAddress" placeholder="请输入所属医院"></a-input>
        </a-form-item>
        <!-- 现在这里改成实名认证 -->
        <a-form-item label="实名认证">
          <a-select
            ref="select"
            v-model:value="advancedForm.nameStatus"
            style="width: 120px"
            @focus="focus"
            placeholder="请选择实名认证状态"
          >
            <a-select-option v-for="item in isNameStatus" :value="item.id" :key="item.id">{{ item.title }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="职称">
          <a-select ref="select" v-model:value="advancedForm.identity" style="width: 120px" @focus="focus" placeholder="请选择当前用户职称">
            <a-select-option v-for="item in idenStatusList" :value="item.id" :key="item.id">{{ item.title }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="状态">
          <a-select ref="select" v-model:value="advancedForm.status" style="width: 120px" @focus="focus" placeholder="请选择当前用户状态">
            <a-select-option v-for="item in statusList" :value="item.id" :key="item.id">{{ item.title }}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="服务质量">
          <a-select ref="select" v-model:value="advancedForm.label" style="width: 120px" @focus="focus" placeholder="请选择">
            <a-select-option v-for="item in statusList1" :value="item.id" :key="item.id">{{ item.title }}</a-select-option>
          </a-select>
        </a-form-item>
      </a-form>
      <a-row style="margin-top: 50px">
        <a-col :span="2" :offset="8">
          <a-button type="primary" size="large" @click="advancedSearch">搜索</a-button>
        </a-col>
        <a-col :span="2" :offset="4">
          <a-button size="large" @click="reset">重置</a-button>
        </a-col>
      </a-row>
    </a-drawer>
    <!-- 发送短信 -->
    <template v-if="msgVisible">
      <SendMsg
        :visible="msgVisible"
        :modalType="modalType"
        :longs="myFinalLong"
        :list="mobileList"
        :nurseDto="{ ...advancedForm, ...form }"
        :userType="myFinalType"
        @closeModal="closeMsg"
      ></SendMsg>
    </template>
  </div>
</template>
<script>
import { Table } from 'ant-design-vue'
import { useModal, useSelects } from '@/hooks'

import { reactive, ref, watch, computed, defineComponent, onMounted, createVNode, toRefs } from 'vue'
import { CheckOutlined, EditOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue'
import { Modal, message } from 'ant-design-vue'
import { useRoute, useRouter, viewDepthKey } from 'vue-router'
import SendMsg from '@/views/user/components/SendMsg'
import { selectAllNurse, selectAllNurseExport, disableNurse, selectAllNurseIds } from '@/api/user/index.js'
import { deleteObjBlank } from '@/assets/js/common.js'
import { nurseType } from '@/utils/dict.js'
import xlsx from 'xlsx' //这个最新版本的会报错最好装低版本本
export default {
  setup() {
    const router = useRouter()
    const route = useRoute()
    const formRef = ref('')
    const form = reactive({
      nickName: '',
      userId: '',
      mobile: ''
    })
    const data = reactive({
      nurseType,
      loading: true,
      list: [],
      advance: false, //是否是高级搜索
      mobileList: [],
      value1: '',
      selectedAll: false,
      msgLoading: false,
      sysLoading: false,
      listPage: 1,
      toListPage: 1,
      toAdvancedForm: '',
      toForm: ''
    })
    const msgVisible = ref(false)
    const modalType = ref(0)
    const rules = {}
    // { orderNumberBegin: 0 }
    const advancedForm = reactive({})
    const isNameStatus = reactive([
      {
        title: '已实名',
        id: 2
      },
      {
        title: '未实名',
        id: 0
      }
    ])
    const isRealNameList = reactive([
      {
        title: '已认证',
        id: 2
      },
      {
        title: '未认证',
        id: 0
      }
    ])
    const idenStatusList = reactive([
      {
        title: '护士',
        id: 1
      },
      {
        title: '护工',
        id: 2
      }
    ])
    const statusList = reactive([
      {
        title: '启用',
        id: 0
      },
      {
        title: '待禁用',
        id: 1
      },
      {
        title: '禁用',
        id: 2
      }
    ])
    const statusMap = reactive({
      0: '启用',
      1: '待禁用',
      2: '禁用'
    })
    const statusList1 = reactive([
      {
        title: '极差',
        id: 1
      },
      {
        title: '一般',
        id: 2
      },
      {
        title: '良好',
        id: 3
      },
      {
        title: '优秀',
        id: 4
      },
      {
        title: '极好的',
        id: 5
      }
    ])
    const registSourceList = reactive([
      {
        title: 'OPPO',
        id: 1
      },
      {
        title: 'HUAWEI',
        id: 2
      },
      {
        title: 'Xiaomi',
        id: 3
      },
      {
        title: 'vivo',
        id: 4
      },
      {
        title: 'ios',
        id: 5
      },
      {
        title: 'HONOR',
        id: 6
      },
      {
        title: 'Apple',
        id: 7
      }
    ])
    const sliderValue = ref([0, 999])
    const marks = ref({
      0: '0',
      999: {
        style: {
          color: '#f50'
        },
        label: '999'
      }
    })

    const visible = ref(false)

    // 分页器
    const page = reactive({
      current: 1,
      pageSize: 10,
      total: 0
    })

    const changeOrderNumber = e => {
      console.log(e, '范围')
      advancedForm.orderNumberBegin = e[0]
      advancedForm.orderNumberEnd = e[1]
    }
    // 查询
    const search = () => {
      console.log(form, '表单内容')
      deleteObjBlank(form)
      data.advance = false
      page.current = 1
      data.toListPage = 1
      data.toForm = ''
      data.toAdvancedForm = ''
      rowSelection.selectedRowKeys = []
      init()
    }
    const selectTime = (e, str) => {
      console.log(e, str, '选择时间')
      advancedForm.createdAtBegin = str[0]
      advancedForm.createdAtEnd = str[1]
    }

    const columns = [
      {
        title: '护士ID',
        dataIndex: 'nurseId',
        className: 'table',
        align: 'center'
      },
      {
        title: '护士姓名',
        dataIndex: 'name',
        className: 'table',
        align: 'center',
        sort: true,
        slots: {
          customRender: 'name'
        }
      },
      {
        title: '手机号',
        dataIndex: 'mobile',
        className: 'table',
        align: 'center'
      },
      {
        title: '地理位置',
        dataIndex: 'address',
        className: 'table',
        align: 'center',
        ellipsis: true
      },
      {
        title: '注册日期',
        dataIndex: 'createdAt',
        className: 'table',
        align: 'center',
        sorter: (a, b) => {
          const aTime = new Date(a.createdAt).getTime()
          const bTime = new Date(b.createdAt).getTime()
          return aTime - bTime
        }
      },
      {
        title: '接单数量',
        dataIndex: 'orderNumber',
        className: 'table',
        align: 'center',
        sorter: (a, b) => {
          return a.orderNumber - b.orderNumber
        }
      },
      {
        title: '注册渠道',
        dataIndex: 'registsource',
        className: 'table',
        align: 'center'
      },
      {
        title: '职称',
        dataIndex: 'identity',
        className: 'table',
        align: 'center',
        slots: {
          customRender: 'identity'
        }
      },
      {
        title: '服务质量',
        dataIndex: 'label',
        className: 'table',
        align: 'center'
      },
      {
        title: '资质认证',
        dataIndex: 'attestStatus',
        className: 'table',
        align: 'center',
        slots: {
          customRender: 'attestStatus'
        }
      },
      {
        title: '实名认证',
        dataIndex: 'nameStatus',
        className: 'table',
        align: 'center',
        slots: {
          customRender: 'nameStatus'
        }
      },
      {
        title: '所属医院',
        dataIndex: 'hospitalAddress',
        className: 'table',
        align: 'center'
      },
      {
        title: '状态',
        dataIndex: 'isDele',
        className: 'table',
        align: 'center',
        slots: {
          customRender: 'status'
        }
      },
      {
        title: '操作',
        dataIndex: 'operation',
        className: 'table',
        align: 'center',
        fixed: 'right',
        slots: {
          customRender: 'operation'
        }
      }
    ]
    // const 3 ref([]);
    // 分页器
    const pagination = computed(() => ({
      current: page.current,
      pageSize: page.pageSize,
      pageSizeOptions: ['10', '20', '30'],
      showTotal: (total, range) => {
        return '共' + total + '条'
      },
      total: page.total,
      showQuickJumper: true,
      showSizeChanger: true
    }))
    const myFinalLong = computed(() => {
      return data.mobileList.length
    })
    const myFinalType = computed(() => {
      return '1'
    })

    // 分页器改变的时候
    const handleTableChange = (pagination, filters, sorter) => {
      console.log(pagination, '当前分页')
      page.current = pagination.current
      data.listPage = page.current
      page.pageSize = pagination.pageSize

      // 请求列表接口
      if (data.advance) {
        // 如果是高级查询
        init(advancedForm)
      } else {
        init()
      }
    }

    const { renderData, rowSelection } = useSelects({
      key: 'nurseId'
    })
    const mergeAndRemoveDuplicates = (array1, array2) => {
      // 创建一个Set来快速查找array2中的元素
      const set2 = new Set(array2)

      // 遍历array1，将不存在的元素添加到set2中，并从set2中删除已存在的元素
      for (const item of array1) {
        if (set2.has(item)) {
          set2.delete(item) // 从set2中删除已存在的元素
        } else {
          set2.add(item) // 将不存在的元素添加到set2中（实际上这一步是多余的，因为set会自动添加唯一元素）
        }
      }

      // 将set2转换回数组，并添加回那些被删除的元素（但实际上它们已经被移除了）
      // 这里我们不需要做这一步，因为set2已经包含了所有要保留的元素
      // const newArray2 = [...set2, ...array1.filter(item => !set2.has(item))]; // 这是错误的，因为我们不想再次添加被删除的元素

      // 直接从set转换回数组，这就是我们要的最终结果
      return [...set2]
    }
    const changeStatus = (e, index) => {
      console.log(e.index, '是否禁用')
      // 弹框提示？确定上下架吗
      const { closeModal } = useModal.confirm({
        title: () => '确定停用当前用户吗?',
        icon: () => createVNode(ExclamationCircleOutlined),
        class: 'test'
      })
    }
    const openDrawer = () => {
      visible.value = true
    }
    //高级筛选重置
    const reset = () => {
      Object.keys(advancedForm).forEach(key => delete advancedForm[key])
      data.value1 = ''
      sliderValue.value = [0, 999]
    }
    // 高级筛选
    const advancedSearch = () => {
      if (Object.keys(advancedForm).length == 0) {
        message.warning('请输入你要搜索的内容！！！')
        return
      }
      page.current = 1
      ;(data.pageNum = 1), (data.toListPage = 1)
      data.toForm = ''
      data.toAdvancedForm = ''
      // init(deleteObjBlank(advancedForm));
      rowSelection.selectedRowKeys = []
      init(advancedForm)
      data.advance = true
      visible.value = false
      // close();
    }
    // /启用
    const enableUser = () => {
      const { closeModal } = useModal.confirm({
        title: '确定启用所选用户吗?',
        icon: createVNode(ExclamationCircleOutlined),
        okText: '确定',
        cancelText: '取消'
      })
    }

    // 导出客户数据
    const exportData = () => {
      if (rowSelection.selectedRowKeys.length == 0) {
        message.warning('请选择你要导出的用户')
        return
      }
      const { closeModal } = useModal.confirm({
        // ${rowSelection.selectedRowKeys.length}条
        title: `确认导出当前${rowSelection.selectedRowKeys.length}条数据吗?`,
        icon: createVNode(ExclamationCircleOutlined),
        okText: '确定',
        cancelText: '取消',
        onOk() {
          let obj = {
            ...form,
            ...advancedForm,
            nurseIds: rowSelection.selectedRowKeys
          }
          selectAllNurseExport({
            ...obj
          }).then(res => {
            console.log(res)
            // console.log(url);
            let link = document.createElement('a')
            //创建一个a标签
            link.style.display = 'none'
            //将a标签隐藏
            link.href = res.object
            //给a标签添加下载链接  "域名+接口"  safe是一个动态的域名  后面的接口替换成你自己的下载接口
            link.setAttribute('download', '护士')
            // 此处注意，要给a标签添加一个download属性，属性值就是文件名称 否则下载出来的文件是没有属性的，空白白
            document.body.appendChild(link)
            //将上面创建的a标签加入到body的尾部
            link.click()
            //执行a标签
            closeModal()
          })
        }
      })
    }
    // 发送短信
    const send = async () => {
      if (rowSelection.selectedRowKeys.length == 0) {
        message.warning('请选择你要发送的用户')
        return
      }
      data.mobileList = rowSelection.selectedRowKeys
      console.log(data.mobileList, '--------')
      console.log(data.mobileList.length, '一共多少护士')
      modalType.value = 0
      msgVisible.value = true
    }
    // 系统通知
    const systemNotice = async () => {
      if (rowSelection.selectedRowKeys.length == 0) {
        message.warning('请选择你要发送的用户')
        return
      }
      data.mobileList = rowSelection.selectedRowKeys
      modalType.value = 1
      msgVisible.value = true
    }

    const closeMsg = () => {
      console.log('关闭信息')
      msgVisible.value = false
    }
    const cancel = () => {
      console.log(111111111)
    }
    const disable = row => {
      const { closeModal } = useModal.confirm({
        // ${rowSelection.selectedRowKeys.length}条
        title: `是否确认禁用该护士禁用后该护士则无法接单及派单?`,
        icon: createVNode(ExclamationCircleOutlined),
        okText: '确定',
        cancelText: '取消',
        onOk() {
          disableNurse({ nurseId: row.nurseId }).then(res => {
            if (res.success) {
              message.success('操作成功')
              init()
            }
            closeModal()
          })
          // let obj = {
          //   ...form,
          //   ...advancedForm,
          //   nurseIds: rowSelection.selectedRowKeys
          // }
          // selectAllNurseExport({
          //   ...obj
          // }).then(res => {
          //   console.log(res)
          //   // console.log(url);
          //   let link = document.createElement('a')
          //   //创建一个a标签
          //   link.style.display = 'none'
          //   //将a标签隐藏
          //   link.href = res.object
          //   //给a标签添加下载链接  "域名+接口"  safe是一个动态的域名  后面的接口替换成你自己的下载接口
          //   link.setAttribute('download', '护士')
          //   // 此处注意，要给a标签添加一个download属性，属性值就是文件名称 否则下载出来的文件是没有属性的，空白白
          //   document.body.appendChild(link)
          //   //将上面创建的a标签加入到body的尾部
          //   link.click()
          //   //执行a标签
          //   closeModal()
          // })
        }
      })
    }
    // 查看
    const look = (key, listPage, form, advancedForm, isLook) => {
      console.log('查看9999999999999', form, listPage, advancedForm)
      if (data.toForm != '') {
        handleForm(data.toForm)
      }
      if (data.toAdvancedForm != '') {
        advancedForm = data.advancedForm
      }
      form = JSON.stringify(form)
      advancedForm = JSON.stringify(advancedForm)
      router.push({
        path: '/user/nurse/nurse-detail',
        query: {
          id: key,
          form: form,
          advancedForm: advancedForm,
          listPage: listPage,
          isLook: isLook
        }
      })
    }

    // 处理
    const deal = (key, isEdit) => {
      router.push({
        path: '/user/nurse/nurse-detail?id=' + key,
        query: {
          isEdit: 1
        }
      })
    }

    function findStr(str, cha, num) {
      let x = str.indexOf(cha)
      for (let i = 0; i < num; i++) {
        x = str.indexOf(cha, x + 1)
      }
      return x
    }

    function handleForm(str) {
      let a = JSON.parse(str)
      console.log('aaaaa', a)
      if (typeof a.mobile != undefined) {
        form.mobile = a.mobile
      }
      if (typeof a.userId != undefined) {
        form.userId = a.userId
      }
      if (typeof a.nickName != undefined) {
        form.nickName = a.nickName
      }
    }
    let detailUrl = decodeURI(router.options.history.state.forward)
    if (detailUrl != null) {
      let sta = detailUrl.indexOf('nurse-detail') != -1
      console.log('sta', detailUrl)
      if (sta) {
        let detailUrlLength = detailUrl.length
        let detailUrlLocation = detailUrl.lastIndexOf('=')
        let endData = detailUrl.substr(detailUrlLocation + 1, detailUrlLength - detailUrlLocation)
        data.toListPage = endData
        data.listPage = endData
        console.log('listPage', data.listPage)
        let formLocationStart = findStr(detailUrl, '=', 1) + 1
        let formLocation = findStr(detailUrl, '&', 1)
        data.toForm = detailUrl.substring(formLocation, formLocationStart)
        console.log('toForm', data.toForm)
        let advanceLocation = detailUrl.lastIndexOf('&')
        let advanceLocationStart = detailUrl.lastIndexOf('=', detailUrl.lastIndexOf('=') - 1) + 1
        data.toAdvancedForm = detailUrl.substring(advanceLocationStart, advanceLocation)
        console.log('toAdvancedForm', data.toAdvancedForm)
        data.advancedForm = JSON.parse(data.toAdvancedForm)
        handleForm(data.toForm)
        console.log('普通搜索data.toForm', form)
      }
      init()
    }
    async function init(search) {
      console.log('search', search)
      console.log(111, data.toAdvancedForm, 222, data.toForm)
      console.log(222, data.advancedForm, 333, data.form)
      if (typeof search == 'undefined') {
        if (data.toAdvancedForm != '{}') {
          console.log('高级222')
          search = data.advancedForm
        } else if (data.toForm != '{}') {
          console.log('普通111')
          handleForm(data.toForm)
        }
      }
      data.loading = true
      deleteObjBlank(form)
      let obj = {
        pageNum: page.current,
        pageSize: page.pageSize,
        ...form,
        ...search //高级表单
      }
      console.log('obj777777777777', obj)
      let res = await selectAllNurse(obj)
      if (res.success) {
        console.log(res, 1034)
        res.object.pagedData.list.map(el => (el.key = el.nurseId))
        let hospitalAddressList = res.object.pagedData.list.map(el =>
          // (el.key = el.hospitalAddress)
          {
            if (el.hospitalAddress == null || el.hospitalAddress == '') {
              el.hospitalAddress = '暂无'
            }
          }
        )
        console.log(hospitalAddressList)
        data.list = res.object.pagedData.list
        page.total = res.object.pagedData.total
        // renderData.value = res.object.allNurseIds
        getSelectAllNurseIds(obj)
      }
      data.loading = false
    }
    const getSelectAllNurseIds = obj => {
      selectAllNurseIds(obj).then(res => {
        renderData.value = res.object
      })
    }
    onMounted(() => {
      console.log('onMountedonMountedonMounted', data.toListPage, data.toForm, data.toAdvancedForm)
      if (data.toListPage != 1 || data.toForm != '{}' || data.toAdvancedForm != '{}' || data.toForm == '' || data.toAdvancedForm == '') {
        page.current = data.toListPage
        console.log(22222222222)
        if (data.toAdvancedForm != '{}' && data.toForm == '{}') {
          init(data.advancedForm)
        } else if (data.toForm != '{}' && data.toAdvancedForm == '{}') {
          init()
        }
      } else if (
        data.toListPage == 1 &&
        (data.toForm == '{}' || data.toForm == '') &&
        (data.toAdvancedForm == '{}' || data.toAdvancedForm == '')
      ) {
        page.current = data.listPage
        console.log(1111111111111111)
        init()
      }
    })
    return {
      isNameStatus,
      idenStatusList,
      ...toRefs(data),
      handleForm,
      findStr,
      formRef,
      form,
      rules,
      columns,
      pagination,
      myFinalType,
      myFinalLong,
      handleTableChange,
      search,
      deal,
      look,
      rowSelection,
      changeStatus,
      labelCol: {
        style: {
          fontWeight: 'bolder',
          width: '100px'
        }
      },
      exportData,
      send,
      systemNotice,
      enableUser,
      visible,
      openDrawer,
      advancedForm,
      isRealNameList,
      statusList,
      statusMap,
      advancedSearch,
      sliderValue,
      marks,
      changeOrderNumber,
      disable,
      msgVisible,
      closeMsg,
      modalType,
      registSourceList,
      cancel,
      selectTime,
      statusList1,
      reset
    }
  },

  components: {
    CheckOutlined,
    EditOutlined,
    ExclamationCircleOutlined,
    SendMsg
  }
}
</script>

<style scoped lang="less">
.img {
  width: 50px;
  height: 50px;
}

.title {
  font-weight: bold;
}

.search {
  background-color: #e6e6e6;
  margin-bottom: 20px;
}
</style>
